/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package demo1028;
import demo1022.*;
import demo1021.*;
import java.sql.*;
import javax.swing.JOptionPane;

/**
 *
 * @author Administrator
 */
public class LoginDemno {
    public static void main(String args[]){
        Connection conn=null;
        PreparedStatement pstat=null;
        ResultSet rs=null;
        try{
       conn=DBConnection.getConnection();
        pstat=conn.prepareStatement("select * from user"
                + " where username=?  and password=?");
        String name=JOptionPane.showInputDialog("input name");
        String password=JOptionPane.showInputDialog("input password");
        
        pstat.setString(1,name);
        pstat.setString(2, password);
        rs=pstat.executeQuery();

       if(rs.next()){
         JOptionPane.showMessageDialog(null, "登陆成功 ");
       }else{
         JOptionPane.showMessageDialog(null, "登陆失败 ");
       }         
        }
        catch(SQLException e){
            System.out.println(e.getMessage());
            
        }
        
        
    }
    
}
